<template>
	<view class="page-body">
		<!-- 页面内容开始 -->

		<!-- 表格搜索组件开始 -->
		<vk-data-table-query v-model="queryForm1.formData" :columns="queryForm1.columns"
			@search="search"></vk-data-table-query>
		<!-- 表格搜索组件结束 -->

		<!-- 自定义按钮区域开始 -->
		<view v-if="vk.vuex.get('$user.userInfo.username') == 'admin'">
			<el-row>
				<el-button type="success" size="small" icon="el-icon-circle-plus-outline" @click="addBtn">添加</el-button>

				<!-- 批量操作 -->
				<el-dropdown v-if="table1.multipleSelection" :split-button="false" trigger="click" @command="batchBtn">
					<el-button type="danger" size="small" style="margin-left: 20rpx"
						:disabled="table1.multipleSelection.length === 0">
						批量操作
						<i class="el-icon-arrow-down el-icon--right"></i>
					</el-button>
					<el-dropdown-menu slot="dropdown">
						<el-dropdown-item :command="1">批量上架</el-dropdown-item>
						<el-dropdown-item :command="2">批量下架</el-dropdown-item>
					</el-dropdown-menu>
				</el-dropdown>
			</el-row>
		</view>
		<!-- 自定义按钮区域结束 -->

		<view v-if="vk.vuex.get('$user.userInfo.username') == 'admin'">
			<!-- 表格组件开始 -->
			<vk-data-table ref="table1" :action="table1.action" :columns="table1.columns" :query-form-param="queryForm1"
				:right-btns="['detail_auto', 'update', 'delete','more']" :right-btns-more="table1.rightBtnsMore"
				:selection="true" :row-no="true" :pagination="true" @update="updateBtn" @delete="deleteBtn"
				@current-change="currentChange" @selection-change="selectionChange"></vk-data-table>
			<!-- 表格组件结束 -->
		</view>

		<view v-else>
			<!-- 表格组件开始 -->
			<vk-data-table ref="table1" :action="table1.action" :columns="table1.columns" :query-form-param="queryForm1"
				:right-btns="['more']" :right-btns-more="table1.rightBtnsMore" :selection="false" :row-no="true"
				:pagination="true" @current-change="currentChange" @selection-change="selectionChange"></vk-data-table>
			<!-- 表格组件结束 -->
		</view>

		<!-- 添加或编辑的弹窗开始 -->
		<vk-data-dialog v-model="form1.props.show" :title="form1.props.title" width="900px" mode="form"
			:close-on-click-modal="false">
			<vk-data-form v-model="form1.data" :rules="form1.props.rules" :action="form1.props.action"
				:form-type="form1.props.formType" :columns="form1.props.columns" label-width="140px" @success="
					form1.props.show = false;
					refresh();
				">
				<template v-slot:footer="{ loading }">
					<view style="text-align: center">
						<el-button :loading="loading" type="danger" style="padding: 10px 40px; margin-right: 30px"
							@click="form1.props.show = false">取消</el-button>
						<el-button :loading="loading" type="success" style="padding: 10px 40px"
							@click="batchAdd(form1.data)">确定</el-button>
					</view>
				</template>
			</vk-data-form>
		</vk-data-dialog>
		<!-- 添加或编辑的弹窗结束 -->
		<!-- 弹窗预览分集数据开始 -->
		<el-dialog title="分集数据预览" :visible.sync="dialogVisible" width="70%" :before-close="handleClose"
			:destroy-on-close="true" :center="true" :close-on-click-modal="false">
			<el-row>
				<el-col :span="12">
					<text style="font-size: large; margin-left: 10rpx">当前播放:第{{ currentserie }}集</text>
					<scroll-view scroll-y="true" style="height: 1250rpx" :show-scrollbar="true">
						<block v-for="(item, index) in temp_series_list" :key="index">
							<el-button type="primary" @click="cut_serie(item)"
								style="width: 170rpx; margin-bottom: 10rpx; margin-left: 10rpx">第{{ item.series }}集</el-button>
						</block>
					</scroll-view>
				</el-col>
				<el-col :span="10">
					<view style="align-content: center; margin-left: 30rpx">
						<video v-if="dialogVisible" id="myVideo" :src="currentlink" controls
							style="width: 700rpx; height: 1300rpx" :autoplay="true"></video>
					</view>
				</el-col>
			</el-row>

			<span slot="footer" class="dialog-footer">
				<el-button @click="dialogVisible = false">关 闭</el-button>
				<el-button type="primary" @click="copylink">复制视频链接并下载</el-button>
			</span>
		</el-dialog>
		<!-- 弹窗预览分集数据结束 -->

		<!-- 页面内容结束 -->
	</view>
</template>

<script>
	var that; // 当前页面对象
	var vk = uni.vk; // vk实例
	var originalForms = {}; // 表单初始化数据
	const db = uniCloud.database();
	const OSS = require('ali-oss');
	export default {
		data() {
			// 页面数据变量
			return {
				store: {},
				baseurl: '',
				tips: '请勿关闭浏览器...',
				currentserie: 1,
				currentlink: '', //当前播放视频链接
				temp_series_list: [],
				dialogVisible: false, //控制弹窗是否开启
				// 页面是否请求中或加载中
				loading: false,
				// init请求返回的数据
				data: {},
				// 表格相关开始 -----------------------------------------------------------
				table1: {
					rightBtnsMore: [{
						title: '分集数据',
						disabled: (item) => {
							//控制该按钮对哪些数据生效
							// return item._id == '63c54f03819ce8640cced33f'
						},
						async onClick(item) {
							vk.callFunction({
								url: 'admin/pages/kh/dsjzxgl/dsj/getTVEpisode',
								title: '请求中...',
								data: {
									item: item
								},
								success: (data) => {
									that.temp_series_list = data.temp_series_list.sort((a, b) => a
										.series - b.series);
									that.currentlink = data.temp_series_list[0].video_src;
								}
							});
							// that.temp_series_list = [];
							// for (var i = 0; i < item.update_witch * 1; i++) {
							// 	let serie = i + 1;
							// 	that.temp_series_list[i] = {
							// 		serie: serie,
							// 		link: item.baseurl + serie + ".mp4"
							// 	}
							// }
							vk.toast(`全剧共${item.all_series}集,已更新：` + item.update_witch);
							// that.currentserie = that.temp_series_list[0].serie;

							// //获取带签名的视频地址
							// let newUrl = await that.getSecUrl(that.temp_series_list[0].link)

							that.dialogVisible = true;
						}
					}],
					// 表格数据请求地址
					action: 'admin/pages/kh/dsjzxgl/dsj/getList',
					// 表格字段显示规则
					columns: [{
							key: 'status',
							title: '上架状态',
							type: 'tag',
							data: [{
									value: false,
									label: '下架',
									tagType: 'default'
								},
								{
									value: true,
									label: '上架',
									tagType: 'success'
								}
							]
						},
						{
							key: '',
							title: '主剧信息',
							type: 'group',
							minWidth: 260,
							align: 'left',
							columns: [
								// { key: "tv_class", title: "分类", type: "text" },
								{
									key: 'tv_name',
									title: '剧名',
									type: 'text'
								},
								{
									key: '_id',
									title: '主剧ID',
									type: 'text'
								},
								{
									key: 'sub_tvname',
									title: '副剧名',
									type: 'text'
								},
								{
									key: 'start_needpay',
									title: '默认收费集数',
									type: 'text'
								},
								{
									key: 'drama_id',
									title: '剧目ID',
									type: 'number'
								},
								{
									key: 'bind_wxAppid',
									title: '媒资管理小程序',
									type: 'string'
								}
							]
						},
						{
							key: '',
							title: '集数',
							type: 'group',
							minWidth: 160,
							align: 'left',
							columns: [{
									key: 'all_series',
									title: '总集数',
									type: 'number'
								},
								{
									key: 'update_witch',
									title: '更新集数',
									type: 'number'
								},
								{
									key: 'is_end',
									title: '是否完结',
									type: 'switch'
								}
							]
						},

						{
							key: 'tv_image',
							title: '封面图',
							type: 'image'
						},

						{
							key: '',
							title: '广告起始集数',
							type: 'group',
							minWidth: 160,
							align: 'left',
							columns: [{
									key: 'gzhbox_start',
									title: '广告开始集数',
									type: 'number'
								},
								{
									key: 'gzhbox_end',
									title: '广告结束集数',
									type: 'number'
								}
							]
						},
						{
							key: '',
							title: '小程序信息',
							type: 'group',
							minWidth: 230,
							align: 'left',
							columns: [{
									key: 'appid',
									title: 'appid',
									type: 'text',
									defaultValue: '未绑定'
								},
								{
									key: 'appname',
									title: '小程序名称',
									type: 'text',
									defaultValue: '未绑定'
								}
							],
							show: ['detail']
						},

						// {"key":"all_like","title":"总点赞次数","type":"number"},
						{
							key: '',
							title: '标签信息',
							type: 'group',
							minWidth: 160,
							align: 'left',
							columns: [{
									key: 'tag_color',
									title: '标签颜色',
									type: 'text'
								},
								{
									key: 'tag_text',
									title: '标签文字',
									type: 'text'
								}
							]
						},

						// { "key": "desc", "title": "介绍", "type": "text" },
						{
							key: 'sort',
							title: '排序',
							type: 'number'
						},
						{
							key: 'rank',
							title: '排行榜名次',
							type: 'number',
							width: 150,
							defaultValue: '未设置'
						},
						{
							key: '_add_time_str',
							title: '添加时间',
							type: 'text',
							width: 200
						}
					],
					// 多选框选中的值
					multipleSelection: [],
					// 当前高亮的记录
					selectItem: ''
				},
				// 表格相关结束 -----------------------------------------------------------
				// 表单相关开始 -----------------------------------------------------------
				// 查询表单请求数据
				queryForm1: {
					// 查询表单数据源，可在此设置默认值
					formData: {},
					// 查询表单的字段规则 fieldName:指定数据库字段名,不填默认等于key
					columns: [{
							key: 'appid',
							title: '选择小程序',
							type: 'select',
							width: 200,
							data: uni.getStorageSync('appid_ARR'),
							mode: '='
						},
						{
							key: 'tv_name',
							title: '电视剧名',
							type: 'text',
							width: 200,
							mode: '%%'
						},
						{
							key: 'status',
							title: '状态',
							type: 'select',
							data: [{
									value: true,
									label: '已上架'
								},
								{
									value: false,
									label: '已下架'
								}
							],
							mode: '='
						}
					]
				},
				form1: {
					// 表单请求数据，此处可以设置默认值
					data: {
						//设置默认值
						bind_wxAppid: '',
						tv_name: '',
						sort: 99,
						is_end: false,
						gzhbox_start: 4,
						gzhbox_end: 12,
						tag_color: '#F20D0D',
						tag_text: '热播',
						start_needpay: 12,
						how_much: 99,
						batch_add: true,
						status: true,
						appid: [],
						appname: [],
						tv_class: '',
						allow_ads: false,
						gzhbox_start: 0,
						gzhbox_end: 0,
						drama_id: '',
						tv_image: ''
					},
					// 表单属性
					props: {
						// 表单请求地址
						action: '',
						// 表单字段显示规则
						columns: [{
								key: 'status',
								title: '上架状态',
								type: 'switch',
								show: ['add']
							},
							{
								key: 'tv_name',
								title: '剧名',
								type: 'text',
								disabled: (formData) => {
									if (formData._id) {
										return true;
									}
								}
							},
							{
								key: 'sub_tvname',
								title: '副剧名',
								type: 'text'
							},
							// {
							// 	"key": "tv_image",
							// 	"title": "封面图",
							// 	"type": "file-select",
							// 	"placeholder": "请选择图片",
							// 	"fileType": "image",
							// 	"limit": 1
							// },
							{
								key: 'bind_wxAppid',
								title: '媒资小程序id',
								type: 'table-select',
								placeholder: '请选择小程序',
								tips: '短剧在那个小程序提审的，就填写那个小程序的appid',
								action: 'admin/pages/kh/xcxpz/xcxgl/getList',
								columns: [{
										key: 'appid',
										title: '小程序id',
										type: 'text',
										idKey: true
									},
									{
										key: 'appname',
										title: '小程序名称',
										type: 'text',
										nameKey: true
									}
								]
							},

							{
								key: 'drama_id',
								title: '剧目ID',
								type: 'number',
								tips: '此处微信公众平台的剧目ID'
							},
							{
								"key": "tv_image",
								"title": "封面图",
								"type": "file-select",
								"placeholder": "请选择图片",
								"fileType": "image",
								"limit": 1
							},
							{
								key: 'all_series',
								title: '总集数',
								type: 'number',
								placeholder: '该剧总集数，填写数字即可'
							},
							{
								key: 'update_witch',
								title: '已更新数',
								type: 'number',
								placeholder: '该剧已更新到多少集'
							},
							{
								key: 'is_end',
								title: '是否完结',
								type: 'switch'
							},
							// { "key": "allow_ads", "title": "允许看广告解锁", "type": "switch" },
							{
								key: 'start_needpay',
								title: '哪一集开始收费',
								type: 'number',
								tips: '仅添加时生效，修改不生效',
								show: ['add']
							},
							{
								key: 'how_much',
								title: '每集多少金豆',
								type: 'number',
								tips: '仅添加时生效，修改不生效',
								show: ['add']
							},
							{
								key: 'gzhbox_start',
								title: '广告开始集',
								type: 'number',
								tips: '填写纯数字，第几集开始广告解锁'
							},
							{
								key: 'gzhbox_end',
								title: '广告结束集',
								type: 'number',
								tips: '填写纯数字，第几集结束广告解锁'
							},
							{
								key: 'sort',
								title: '排序',
								type: 'number',
								placeholder: '排序值越小排序越靠前'
							},
							{
								key: 'rank',
								title: '排行名次',
								type: 'number',
								placeholder: '在排行榜排多少名'
							},
							{
								key: 'desc',
								title: '剧情介绍',
								type: 'textarea',
								autosize: {
									minRows: 3,
									maxRows: 10
								},
								maxlength: 300,
								showWordLimit: true
							},

							{
								key: 'appname',
								title: '绑定小程序',
								tips: '不选则在所有小程序展示',
								type: 'table-select',
								placeholder: '选择',
								action: 'admin/pages/kh/xcxpz/xcxgl/getList',
								columns: [{
										key: 'appid',
										title: '小程序appid',
										type: 'text',
										nameKey: true
									},
									{
										key: 'appname',
										title: '小程序名称',
										type: 'text',
										idKey: true
									}
								],
								multiple: true,
								watch: (res) => {
									// console.log("watch", res.option)
									this.form1.data.appid = vk.pubfn.arrayObjectGetArray(res.option, 'appid');
								}
							},
							{
								key: 'appname',
								title: '小程序名称',
								type: 'text',
								disabled: true,
								tips: '不选表示在所有小程序展示'
							},
							{
								key: 'tag_text',
								title: '标签文字',
								type: 'text'
							},
							{
								key: 'tag_color',
								title: '标签颜色',
								type: 'color'
							},
							{
								key: 'batch_add',
								title: '是否批量添加集数',
								type: 'switch',
								tips: '特别注意：开启此项请务必正确填写【剧目ID】',
								show: ['add']
							}
						],
						// 表单验证规则
						rules: {
							tv_name: [{
								required: true,
								message: '剧名必须填写',
								trigger: ['blur', 'change']
							}],
							tv_image: [{
								required: true,
								message: '封面图必填',
								trigger: ['blur', 'change']
							}],
							drama_id: [{
								required: true,
								message: '剧目ID必填',
								trigger: ['blur', 'change']
							}],
							gzhbox_start: [{
								required: true,
								message: '第几集开始弹出关注公众号提醒',
								trigger: ['blur', 'change']
							}],
							gzhbox_end: [{
								required: true,
								message: '第几集结束弹出关注公众号提醒',
								trigger: ['blur', 'change']
							}],
							cate: [{
								required: true,
								message: '分类必填',
								trigger: ['blur', 'change']
							}],
							index_cate: [{
								required: true,
								message: '分类必填',
								trigger: ['blur', 'change']
							}],
							all_series: [{
									required: true,
									message: '必须填写总集数，且必须是纯数字',
									trigger: ['blur', 'change']
								},
								{
									type: 'number',
									message: '必须是数字',
									trigger: ['blur', 'change']
								}
							],
							start_needpay: [{
								required: true,
								message: '开始付费集数必填',
								trigger: ['blur', 'change']
							}],
							how_much: [{
								required: true,
								message: '付费金额必填',
								trigger: ['blur', 'change']
							}],
							update_witch: [{
								required: true,
								message: '更新集数必填',
								trigger: ['blur', 'change']
							}],
							tag_text: [{
								required: true,
								message: '标签必填',
								trigger: ['blur', 'change']
							}],
							index_box: [{
								required: true,
								message: '不可为空',
								trigger: ['blur', 'change']
							}]
						},
						// add 代表添加 update 代表修改
						formType: '',
						// 是否显示表单的弹窗
						show: false
					}
				},
				// 其他弹窗表单
				formDatas: {}
				// 表单相关结束 -----------------------------------------------------------
			};
		},
		// 监听 - 页面每次【加载时】执行(如：前进)
		onLoad(options = {}) {
			that = this;
			vk = that.vk;
			that.options = options;
			that.init(options);
		},
		// 监听 - 页面【首次渲染完成时】执行。注意如果渲染速度快，会在页面进入动画完成前触发
		async onReady() {
			const alioss = await db
				.collection('a_config')
				.where({
					name: 'alioss'
				})
				.get();
			// vk.setVuex('$app.ossinfo', ossinfo) //把阿里云oss配置存到本地缓存

			if (alioss.result.data[0]) {
				let ossinfo = alioss.result.data[0];
				this.store = new OSS({
					// yourRegion填写Bucket所在地域。以华东1（杭州）为例，yourRegion填写为oss-cn-hangzhou。
					region: ossinfo.region,
					// 阿里云账号AccessKey拥有所有API的访问权限，风险很高。强烈建议您创建并使用RAM用户进行API访问或日常运维，请登录RAM控制台创建RAM用户。
					accessKeyId: ossinfo.accessKeyId,
					accessKeySecret: ossinfo.accessKeySecret,
					// 填写Bucket名称。
					bucket: ossinfo.bucket
				});
				this.baseurl = ossinfo.baseurl;
			} else {
				this.store = new OSS({
					// yourRegion填写Bucket所在地域。以华东1（杭州）为例，yourRegion填写为oss-cn-hangzhou。
					region: 'test',
					// 阿里云账号AccessKey拥有所有API的访问权限，风险很高。强烈建议您创建并使用RAM用户进行API访问或日常运维，请登录RAM控制台创建RAM用户。
					accessKeyId: 'test',
					accessKeySecret: 'test',
					// 填写Bucket名称。
					bucket: 'test'
				});
				this.baseurl = '';
			}
		},
		// 监听 - 页面每次【显示时】执行(如：前进和返回) (页面每次出现在屏幕上都触发，包括从下级页面点返回露出当前页面)
		onShow() {
			console.log('oss=', vk.vuex.get('$app.ossinfo.region'));
		},
		// 监听 - 页面每次【隐藏时】执行(如：返回)
		onHide() {},
		// 函数
		methods: {
			async cut_serie(item) {
				// vk.toast(link, 'none');
				//获取带签名的视频地址
				// let newUrl = await this.getSecUrl(item.link)
				// console.log("newUrl=", newUrl);
				// this.currentlink = newUrl;

				// this.currentserie = item.serie;
				this.currentlink = item.video_src;
				this.currentserie = item.series;
			},
			async getSecUrl(tempUrl) {
				//如果数据库里没配置相关参数，则原样返回
				if (!this.baseurl) {
					return tempUrl;
				}
				let suffix = tempUrl.substr(-4); //截取后四位,如果后4位不是.mp4，说明已经获取过签名
				console.log('suffix=', suffix);
				if (suffix == '.mp4' || suffix == '.MP4') {
					//避免有些文件是http，因此统一替换成https
					tempUrl = tempUrl.replace('http://', 'https://');
					//清空域名信息，只留文件名信息，例如：anna/1.mp4
					let videoFile = tempUrl.replace(this.baseurl, '');
					//生成带签名的url
					let url = this.store.signatureUrl(videoFile, {
						expires: 3600 //3600秒到期
					});
					return url;
				} else {
					return tempUrl;
				}
			},
			async batchAdd(item) {
				//如果已存在_id,就是编辑，否则就是新增（此处只能是已_id为判定条件）
				if (item._id) {
					vk.callFunction({
						url: 'admin/pages/kh/dsjzxgl/dsj/update',
						title: '请求中...',
						data: {
							...item
						},
						success: (data) => {
							this.form1.props.show = false; //关闭编辑窗口
							this.refresh();
						}
					});
					return;
				} else {
					if (!this.form1.data.update_witch) {
						vk.alert('必须填写更新集数');
						return;
					}
					if (!this.form1.data.bind_wxAppid) {
						vk.alert('必须选择媒资小程序');
						return;
					}

					if (!this.form1.data.tv_name || !this.form1.data.drama_id || !this.form1.data.tv_image) {
						vk.alert('参数不完整，请检查必填项');
						return;
					}

					if (!this.form1.data.all_series || !this.form1.data.start_needpay || !this.form1.data.how_much) {
						vk.alert('参数不完整，请检查必填项');
						return;
					}

					if (this.form1.data.gzhbox_start == '' || this.form1.data.gzhbox_end == '' || !this.form1.data
						.tag_text) {
						if (this.form1.data.gzhbox_start != 0 || this.form1.data.gzhbox_end != 0) {
							vk.alert('参数不完整，请检查必填项');
							return;
						}
					}

					// if (this.form1.data.tv_class == "") {
					// 	vk.alert('短剧分类必须填写，请检查必填项');
					// 	return;
					// }
					let addtv = '';
					await vk.callFunction({
						url: 'admin/pages/kh/dsjzxgl/dsj/add',
						title: '请求中...',
						data: {
							...item
						},
						success: (data) => {
							this.form1.props.show = false; //关闭编辑窗口
							addtv = data.id;
							this.refresh();
						}
					});

					let timenow = new Date().getTime();

					if (!this.form1.data.batch_add) {
						console.log('未开启批量添加');
						vk.alert('已完成，本次未开启批量添加');
						this.form1.props.show = false; //关闭编辑窗口
						this.refresh();
						return;
					}

					let update_series = this.form1.data.update_witch;
					for (var i = 0; i < update_series; i++) {
						uni.showToast({
							title: i + '/' + update_series + '，请勿关闭浏览器...',
							icon: 'loading'
						});
						let serie = i + 1;
						let pay_bean = this.form1.data.how_much; //初始值为前端传过来的how_much金豆
						//未到收费集数，则收费为0
						if (serie < this.form1.data.start_needpay) {
							pay_bean = 0;
						}
						let add = await db.collection('a_tv_series').add({
							tv_id: addtv,
							tv_name: this.form1.data.tv_name,
							tv_image: this.form1.data.tv_image,
							series: serie,
							pay: pay_bean,
							title: this.form1.data.tv_name + ' - 第' + serie + '集',
							is_recommend: false,
							appid: [],
							appname: [],
							_add_time: timenow,
							_add_time_str: vk.pubfn.timeFormat(new Date(), 'yyyy-MM-dd hh:mm:ss') || '0'
						});
					}
					this.form1.props.show = false; //关闭编辑窗口
					vk.alert('恭喜！添加完成');
					this.refresh();
				}
			},
			copylink() {
				let that = this;
				uni.downloadFile({
					url: this.currentlink,
					header: {
						'content-type': 'application/x-www-form-urlencoded'
					},
					success: (res) => {}
				});
				uni.setClipboardData({
					data: this.currentlink,
					success() {
						// vk.toast('复制成功', 'none');
						that.$message({
							message: '视频链接复制成功：' + that.currentlink,
							type: 'success'
						});
					}
				});
			},

			//弹窗关闭前做一下判断或操作
			handleClose() {
				this.dialogVisible = false;
			},
			// 页面数据初始化函数
			init(options) {
				originalForms['form1'] = vk.pubfn.copyObject(that.form1);
			},
			// 页面跳转
			pageTo(path) {
				vk.navigateTo(path);
			},
			// 表单重置
			resetForm() {
				vk.pubfn.resetForm(originalForms, that);
			},
			// 搜索
			search() {
				that.$refs.table1.search();
			},
			// 刷新
			refresh() {
				that.$refs.table1.refresh();
			},
			// 获取当前选中的行的数据
			getCurrentRow() {
				return that.$refs.table1.getCurrentRow();
			},
			// 监听 - 行的选中高亮事件
			currentChange(val) {
				that.table1.selectItem = val;
			},
			// 当选择项发生变化时会触发该事件
			selectionChange(list) {
				that.table1.multipleSelection = list;
			},
			// 显示添加页面
			addBtn() {
				that.resetForm();
				that.form1.props.action = 'admin/pages/kh/dsjzxgl/dsj/add';
				that.form1.props.formType = 'add';
				that.form1.props.title = '添加';
				that.form1.props.show = true;
			},
			// 显示修改页面
			updateBtn({
				item
			}) {
				that.form1.props.action = 'admin/pages/kh/dsjzxgl/dsj/update';
				that.form1.props.formType = 'update';
				that.form1.props.title = '编辑';
				that.form1.props.show = true;
				that.form1.data = item;
			},
			// 删除按钮
			deleteBtn({
				item,
				deleteFn
			}) {
				deleteFn({
					action: 'admin/pages/kh/dsjzxgl/dsj/delete',
					data: {
						_id: item._id
					}
				});
			},
			// 监听 - 批量操作的按钮点击事件
			batchBtn(index) {
				switch (index) {
					case 1:
						vk.callFunction({
							url: 'admin/pages/kh/dsjzxgl/dsj/batchup',
							title: '请求中...',
							data: {
								lists: this.table1.multipleSelection
							},
							success: (data) => {
								console.log('执行完成');
								this.refresh();
							}
						});
						break;
					case 2:
						vk.callFunction({
							url: 'admin/pages/kh/dsjzxgl/dsj/batchdown',
							title: '请求中...',
							data: {
								lists: this.table1.multipleSelection
							},
							success: (data) => {
								console.log('执行完成');
								this.refresh();
							}
						});
						break;
					default:
						break;
				}
			}
		},
		// 监听属性
		watch: {},
		// 过滤器
		filters: {},
		// 计算属性
		computed: {}
	};
</script>
<style lang="scss" scoped>
	.page-body {}

	// 滚动条样式
	/deep/ ::-webkit-scrollbar {
		/*滚动条整体样式*/
		width: 4px !important;
		height: 1px !important;
		overflow: auto !important;
		background: #ccc !important;
		-webkit-appearance: auto !important;
		display: block;
	}

	/deep/ ::-webkit-scrollbar-thumb {
		/*滚动条里面小方块*/
		border-radius: 10px !important;
		box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2) !important;
		background: #7b7979 !important;
	}

	/deep/ ::-webkit-scrollbar-track {
		/*滚动条里面轨道*/
		// box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2) !important;
		// border-radius: 10px !important;
		background: #ffffff !important;
	}
</style>